package com.midea.ai.air.ui.more;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TextView;

import com.midea.ai.air.R;
import com.midea.ai.air.common.BaseActivity;
import com.midea.ai.air.ui.more.adapter.MoreSettingAirExpertShowTempAdapter;
import com.midea.ai.air.ui.user.LoginActivity;
import com.midea.ai.air.view.MyTitleBar;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by hww on 2016/3/29.
 */
public class MoreSettingAirExpertShowTemp extends BaseActivity implements View.OnClickListener {

    private TextView actionbar_left_tv, actionbar_center_tv;
    private ListView listView;
    public static String POSITION_SHOW_TEMP = "AIR_EXPERT_POSITION_SHOW_TEMP";
    public static String TEMP_SHOW_TEMP = "AIR_EXPERT_TEMP_SHOW_TEMP";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_moresettingairexpertshowtemp);

        init();
    }


    MyTitleBar myTitleBar;

    private void init() {
        int temp = getIntent().getIntExtra(MoreSettingAirExpert.TEMP, 30);
        myTitleBar = new MyTitleBar(this);
        myTitleBar.setActionBar_center(temp + "℃");
        myTitleBar.setActioBar_left(true, R.drawable.register_titler_left, R.string.more_setting_air_expert);
        myTitleBar.setActionBar_right(false, 0);

        actionbar_left_tv = (TextView) findViewById(R.id.actionbar_tv_left);
        actionbar_left_tv.setTextColor(getResources().getColor(R.color.electric_histogram));

        listView = (ListView) findViewById(R.id.more_setting_air_expert_show_temp_listView);
        listView.setAdapter(new MoreSettingAirExpertShowTempAdapter(this, getData()));

        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                LoginActivity.mLog("position = " + position);
                Intent intent = new Intent(MoreSettingAirExpertShowTemp.this, MoreSettingAirExpertShowWeek.class);
                intent.putExtra(POSITION_SHOW_TEMP, getWeek(position));
                startActivity(intent);
            }
        });
    }

    List<air_expert_show_temp> listData;

    private List<air_expert_show_temp> getData() {
        listData = new ArrayList<air_expert_show_temp>();
        for (int i = 0; i < 7; i++) {
            air_expert_show_temp ct = new air_expert_show_temp();
            ct.setDate("2015年12月" + (23 + i) + "日" + getWeek(i));
            ct.setTime(0);
            listData.add(ct);
        }
        return listData;
    }

    private String getWeek(int i) {
        String date = null;
        switch (i) {
            case 0:
                date = "周一";
                break;
            case 1:
                date = "周二";
                break;
            case 2:
                date = "周三";
                break;
            case 3:
                date = "周四";
                break;
            case 4:
                date = "周五";
                break;
            case 5:
                date = "周六";
                break;
            case 6:
                date = "周日";
                break;
            default:
                break;
        }
        return date;
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.actionbar_left_relativeLayout:

                finish();
                break;
            case R.id.actionbar_tv_right:

                break;
        }
    }

    public class air_expert_show_temp {
        private String Date;//温度
        private int time;//时间(小时)

        public String getDate() {
            return Date;
        }

        public void setDate(String date) {
            Date = date;
        }

        public int getTime() {
            return time;
        }

        public void setTime(int time) {
            this.time = time;
        }
    }

}
